<template>
  <c-select
    v-bind="$attrs"
    v-on="$listeners"
    :value="value"
    :options="options"
    :props="props"
  ></c-select>
</template>

<script>
import { mapGetters } from 'vuex'
import { limitNormalParams } from '@/bank/views/limit/mixins'

export default {
  components: {},
  mixins: [limitNormalParams],
  props: {
    value: String,
  },
  model: {
    prop: 'value',
    event: 'change',
  },
  data() {
    return {
      tableName: 'un_gua_batch',
      loading: false,
      options: [],
      props: {
        label: 'batch_no',
        value: 'batch_no',
      },
    }
  },
  computed: {
    ...mapGetters(['clientId']),
  },
  watch: {},
  created() {
    this.getData()
  },
  mounted() {},
  methods: {
    getData() {
      this.loading = true
      this.$api
        .getData(
          this.$serviceName,
          this.tableName,
          {
            ...this.normalParams,
            'un_gua_type.eq': 1,
            'import_status.eq': '', // 重置normalParams
            'is_replace.eq': '', // 重置normalParams
            groupFields: ['batch_no'],
            fields: ['batch_no', 'create_time'],
          },
          {
            create_time: 'desc',
          }
        )
        .then(res => {
          this.options = res?.data ?? []
        })
        .finally(() => {
          this.loading = false
        })
    },
  },
}
</script>

<style lang="scss" scoped></style>
